home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1999 August / Macworld (1999-08).dmg / Shareware World / Info / For Developers / MADE 1.4.0 / Essentials / Essential Shell.c < prev   
C/C++ Source or Header  |  1999-05-26  |  3KB  |  120 lines

  1. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  2. /*                                                                   */
  3. /*        MADE - Macintosh Application Development Essentials        */
  4. /*        ---------------------------------------------------        */
  5. /*           (c) Sig Software, http://www.sigsoftware.com/           */
  6. /*                                                                   */
  7. /* These files can only be used for experimental purposes. To obtain */
  8. /* fully commented code, source code for the functions in Essential  */
  9. /*   Extras.h and permission for usage in final projects, you must   */
  10. /*    purchase a license. See documentation for more information.    */
  11. /*                                                                   */
  12. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  13. /*                                                                   */
  14. /*  Essential Shell.c                                                */
  15. /*  -----------------                                                */
  16. /*                                                                   */
  17. /*  Application entry point, initialisations and Gestalt checking.   */
  18. /*                                                                   */
  19. /*  Version 1.0.0 - 10th November 1996                               */
  20. /*  Version 1.0.1 - 4th June 1997 - Fixed macro, function names      */
  21. /*  Version 1.1.0 - 29th January 1998 - New OS function names        */
  22. /*  Version 1.1.1 - 19th June 1998 - Casts for InitialiseMemory      */
  23. /*                                                                   */
  24. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  25.  
  26. #include "Essential Headers.h"
  27. #include "Essential Prototypes.h"
  28.  
  29. Boolean        applicationHasQuit=false;
  30. void*        dummy;
  31.  
  32. void main()
  33. {
  34.     Error    error=0;
  35.     InitGraf(&qd.thePort);
  36.     InitFonts();
  37.     InitWindows();
  38.     InitMenus();
  39.     TEInit();
  40.     InitDialogs(0L);
  41.     InitCursor();
  42.     MoreMasters();
  43.     MaxApplZone();
  44.  
  45. #if Use_AppleEvents
  46.     
  47.     if (CheckGestaltBit(gestaltAppleEventsAttr, gestaltAppleEventsPresent)) {
  48.         error=InitAppleEvents();
  49.         TestError(error);
  50. #if Insist_On_AppleEvent_Support
  51.         _i(error)
  52. #endif
  53.     } else {
  54. #if Insist_On_AppleEvent_Support
  55.         TestError(System_Software_Version_Error);
  56.         _g
  57. #endif
  58.     } 
  59.  
  60. #endif
  61.             
  62. #if Use_Drag_Manager
  63.  
  64.     if (CheckGestaltBit(gestaltDragMgrAttr, gestaltDragMgrPresent)) {
  65.         error=InitDragManager();
  66.         TestError(error);
  67. #if Insist_On_Drag_Manager_Support
  68.         _i(error)
  69. #endif
  70.     } else {
  71. #if Insist_On_Drag_Manager_Support
  72.         TestError(System_Software_Version_Error);
  73.         _g
  74. #endif
  75.     } 
  76.     
  77. #endif
  78.  
  79. #if Project_Under_Development && Initialise_Allocated_Memory
  80.     dummy=(void*)NewPtr(MaxMem((Size*)&dummy));
  81.     if (dummy) {
  82.         InitialiseMemory((char*)dummy, GetPtrSize((Ptr)dummy));
  83.         DisposePtr((Ptr)dummy);
  84.     }
  85. #endif
  86.  
  87.     error=InitMenuBar();
  88.         TestError(error);
  89.         _i(error)
  90.     
  91.     error=MyInitialiseApplication();
  92.         _i(error)
  93.  
  94.     ExecutionBody();
  95.     
  96.     _e
  97. }
  98.  
  99. void ExecutionBody()
  100. {
  101.     while (!applicationHasQuit)
  102.         MainEventLoop();
  103.     
  104.     MyClearUpApplication();
  105.     
  106.     ExitToShell();
  107. }
  108.  
  109. Boolean CheckGestaltBit(OSType selector, char bit)
  110. {
  111.     long         response;
  112.     
  113.     if (Gestalt(selector, &response))
  114.         return false;
  115.     else if (!(response&(1<<bit)))
  116.         return false;
  117.     else
  118.         return true;
  119. }
  120.